package leetcode;

/**
 * @Author: Yangu
 * @Created time: 2021/2/3 22:51
 * @Description :
 */
public class SymmetricTree101 {



    public boolean isSymmetric(TreeNode root) {
       return check(root, root);

    }

    private boolean check(TreeNode p, TreeNode q) {
        if(p == null && q == null) {
            return true;
        }
        if(p == null || q == null) {
            return false;
        }
        return p.val == q.val && check(p.left, q.right) && check(p.right, q.left);
    }


    public boolean isSymmetric2(TreeNode root) {
        if(root == null) return true;


    }

    class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode() {
        }

        TreeNode(int val) {
            this.val = val;
        }

        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }



        @Override
        public int hashCode() {
            int result = val;
            result = 31 * result + (left != null ? left.hashCode() : 0);
            result = 31 * result + (right != null ? right.hashCode() : 0);
            return result;
        }
    }

    public static void main(String[] args) {
        new SymmetricTree101().isSymmetric()
    }
}
